<?php
class ControllerUploadUpload extends Controller {
	private $error = array();
	public function index()
	{
		//-------------------------------------------------------------------------//
		// Check login
		//-------------------------------------------------------------------------//
		if (!$this->customer->isLogged()) {
			$this->session->data['redirect'] = $this->url->https('upload/upload');
			$this->redirect($this->url->https('account/login'));
		}
		$this->language->load('common/header');
		$this->language->load('common/home');
		$this->load->model('upload/shop');
		$this->load->model('upload/product');
		//-------------------------------------------------------------------------//
		// get Shop Name
		//-------------------------------------------------------------------------//
		$customer_id = $this->customer->getId();
		$shop_name   = $this->model_upload_shop->getShopNameByCustomerId($customer_id);
		if(isset($shop_name)
			&& ( is_array($shop_name) == true )
			&& ( empty($shop_name) == false) ){
			$this->data['shop_name'] = $shop_name[0]["shop_name"];
		}
		$this->document->title = sprintf($this->language->get('title'), $this->config->get('config_store'));
		$this->document->description = $this->config->get('config_meta_description');
		$this->document->home_flg    = "on";

		$this->document->breadcrumbs = array();
		$this->document->breadcrumbs[] = array(
        	'href'      => $this->url->http('common/home'),
        	'text'      => $this->language->get('text_home'),
        	'separator' => FALSE
      	);
      	$this->document->breadcrumbs[] = array(
        	'href'      => $this->url->http('upload/upload'),
        	'text'      => $this->language->get('text_uploadtosell'),
        	'separator' => $this->language->get('text_separator')
      	);

      	$this->load->model('catalog/category');
		$this->data['categories'] = $this->model_catalog_category->getCategories(0);
		$this->load->model('catalog/category');
		$this->data['categories'] = $this->model_catalog_category->getCategories(0);
		if (isset($this->request->post['product_category'])) {
			$this->data['product_category'] = $this->request->post['product_category'];
		} elseif (isset($product_info)) {
			$this->data['product_category'] = $this->model_catalog_product->getProductCategories($this->request->get['product_id']);
		} else {
			$this->data['product_category'] = array();
		}

		$this->load->model('catalog/product');
		$this->load->model('catalog/review');
		$this->load->model('tool/seo_url');
		$this->load->helper('image');

		//----------------------------------------------------------------------------------//
		// get area
		//----------------------------------------------------------------------------------//
		//$are = array("zone_id" => "", "name" => "Chon Khu Vuc");
		$this->load->model('localisation/zone');
    	$area = $this->model_localisation_zone->getZonesByCountryId(230);
		//$area = array_pad($area, - (count($area) + 1), $are);
    	$this->data['areas']  = $area;

		$this->data['action'] = $this->url->http('upload/product/insert');
		//-------------------------------------------------------------------------//
		// get parent catalog
		//-------------------------------------------------------------------------//
		$catalog_arr = $this->model_upload_product->getParentCategories();
		array_unshift($catalog_arr, array("catalog_id" => "","name"=>"Chọn danh mục cấp 1"));
		$this->data['parent_catalog'] = $catalog_arr;
		$this->id       = 'content';
		$this->template = $this->config->get('config_template') . 'uploadtosell/uploadtosell.phtml';
		$this->layout   = 'common/layout_uploadtosell';
		$this->render();
	}
}
?>